<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>布局页面</title>
		<!--导入jquery-->
		<script src="../js/jquery-1.8.3.js"></script>
		<script type="text/javascript" src="../js/easyui/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../js/easyui/locale/easyui-lang-zh_CN.js"></script>
		<link rel="stylesheet" href="../js/easyui/themes/default/easyui.css" />
		<link rel="stylesheet" href="../js/easyui/themes/icon.css" />
		<!-- 引入ztree -->
		<script src="../js/ztree/jquery.ztree.all-3.5.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="../js/ztree/zTreeStyle.css" />
		<script>
			$(function() {
				$("#czbkLink").click(function() {
					//alert(1)
					$('#tt').tabs('add', {

						title: '传智播客',

						content: '欢迎来到德莱联盟',

						closable: true
					});
				});
			});
			// 页面加载后执行
			$(function() {
				// 1、 进行ztree菜单设置 
				var setting = {
					data: {
						simpleData: {
							enable: true // 支持简单json数据格式
						}
					},
					callback: {
						onClick: function(event, treeId, treeNode, clickFlag) {
							var content = '<div style="width:100%;height:100%;overflow:hidden;">' +
								'<iframe src="' +
								treeNode.page +
								'" scrolling="auto" style="width:100%;height:100%;border:0;" ></iframe></div>';

							// 没有page树形菜单，不打开选项卡
							if(treeNode.page != undefined && treeNode.page != "") {
								// 如果选项卡已经打开，选中 
								if($("#tt").tabs('exists', treeNode.name)) {
									// 选中选项卡
									$("#tt").tabs('select', treeNode.name);
								} else {
									// 如果没有打开，添加选项卡 
									$("#tt").tabs('add', {
										title: treeNode.name,
										content: content,
										closable: true
									});
								}
							}
						}
					}
				};

				// 2、提供ztree树形菜单数据 
				var zNodes = [
					{ id: 1, pId: 0, name: "父节点一" },
					{ id: 2, pId: 0, name: "父节点二" },
					{ id: 11, pId: 1, name: "子节点一" },
					{ id: 12, pId: 1, name: "子节点二" },
					{ id: 13, pId: 2, name: "传智播客", page: "http://www.itcast.cn" },
					{ id: 14, pId: 2, name: "百度", page: "https://www.baidu.com" }
				];

				

				// 3、生成菜单
				$.fn.zTree.init($("#baseMenu"), setting, zNodes);
				
				//对象选项卡右键事件
				$('#tt').tabs({

					

					onContextMenu: function(e,title,index) {
						/*阻止默认菜单*/
						e.preventDefault();
						$("#mm").menu('show', {

						left: e.pageX,

						top: e.pageY

				})

					}

				});

				
			});
		</script>
	</head>

	<body class="easyui-layout">
		<div data-options="region:'north',title:'North Title',split:true" style="height:100px;"></div>

		<div data-options="region:'south',title:'South Title',split:true" style="height:100px;"></div>

		<div data-options="region:'east',iconCls:'icon-reload',title:'East',split:true" style="width:100px;"></div>

		<div data-options="region:'west',title:'菜单导航',split:true" style="width:200px;">
			<div id="aa" class="easyui-accordion" style="width:300px;height:200px;" data-options="fit:true">

				<div title="基础菜单">
					<a href="javascript:void(0)" id="czbkLink">传智播客</a>
					<ul id="baseMenu" class="ztree"></ul>
				</div>

				<div title="系统菜单">

				</div>

			</div>

		</div>

		<div data-options="region:'center',title:'消息中心'" style="padding:5px;background:#eee;">
			<div id="tt" class="easyui-tabs" data-options="fit:true">

			</div>

		</div>

		<!--菜单初始化隐藏的-->
		<div id="mm" class="easyui-menu">
			<div>关闭当前窗口</div>
			<div class="menu-sep"></div>
			<div>关闭其它窗口</div>
			<div class="menu-sep"></div>
			<div data-options="iconCls: 'icon-cancel'">关闭全部窗口</div>

		</div>

	</body>

</html>